package com.samphanie.auiu.demo.tab

import android.os.Bundle
import android.widget.Toast
import androidx.annotation.NonNull
import androidx.annotation.Nullable
import androidx.appcompat.app.AppCompatActivity
import com.samphanie.auiu.R
import com.samphanie.auiu.ui.tab.common.IAuiuTabLayout
import com.samphanie.auiu.ui.tab.top.AuiuTabTopInfo
import com.samphanie.auiu.ui.tab.top.AuiuTabTopLayout


class AuiuTabTopDemoActivity : AppCompatActivity() {

    var tabsStr = arrayOf(
        "热门",
        "服装",
        "数码",
        "鞋子",
        "零食",
        "家电",
        "汽车",
        "百货",
        "家居",
        "装修",
        "运动"
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_auiu_tab_top_demo)

        initTabTop()
    }

    private fun initTabTop() {
//        var auiuTabTopLayout = findViewById<AuiuTabTopLayout>(R.id.tab_top_layout)
//        var infoList : List<AuiuTabTopInfo<*>>? = listOf()
//
//        val defaultColor: Int = resources.getColor(R.color.tabBottomDefaultColor)
//        val tintColor: Int = resources.getColor(R.color.tabBottomTintColor)
//
//        for (s in tabStr) {
//            val info: AuiuTabTopInfo<*> = AuiuTabTopInfo<Color>(s, defaultColor, tintColor)
//        }

        val hiTabTopLayout: AuiuTabTopLayout = findViewById(R.id.tab_top_layout)
        val infoList: MutableList<AuiuTabTopInfo<*>> = ArrayList()
        val defaultColor = resources.getColor(R.color.tabBottomDefaultColor)
        val tintColor = resources.getColor(R.color.tabBottomTintColor)
        for (s in tabsStr) {
            val info: AuiuTabTopInfo<*> = AuiuTabTopInfo(s, defaultColor, tintColor)
            infoList.add(info)
        }
        hiTabTopLayout.inflateInfo(infoList)


        hiTabTopLayout.addTabSelectedChangeListener { index, prevInfo, nextInfo ->
            Toast.makeText(this@AuiuTabTopDemoActivity, nextInfo.name, Toast.LENGTH_SHORT)
                .show()
        }

        hiTabTopLayout.defaultSelected(infoList[0])

    }

}